package com.dingding.service.user.facade;

import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.dingding.common.core.beans.WechatUser;
import com.dingding.common.core.util.ToolUtil;
import com.dingding.facade.user.service.IWechatUserManageFacade;
import com.dingding.service.user.core.dao.IWechatUserDao;

/**
 * @Description: 微信用户管理业务
 * @author fengshuonan
 * @date 2016年4月30日 下午2:29:33
 */
@Component("wechatUserManageFacade")
public class WechatUserManageFacade implements IWechatUserManageFacade {
	
	@Resource(name="wechatUserDao")
	private IWechatUserDao wechatUserDao;
	
	/**
	 * @Description: 添加用户关注公众号的信息
	 * @param wechatUser
	 * @author fengshuonan
	 * @return void
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED)
	public void addUserSubscribe(WechatUser wechatUser) {

		if(wechatUser == null)
			return;
		
		this.wechatUserDao.addUserSubscribe(wechatUser);
	}

	
	/**
	 * @Description: 验证该公众号是否已经关注
	 * @param openId 微信公众号
	 * @author fengshuonan
	 * @return boolean true 已经关注  false  没有关注
	 */
	@Override
	@Transactional(readOnly = true)
	public boolean validateUserIsSub(String openId) {
		
		if(ToolUtil.isBlank(openId))
			return true;
		
		return this.wechatUserDao.validateUserIsSub(openId);
	}
	
}
